package day21;
import java.util.*;

public class A2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            int n = in.nextInt(),m = in.nextInt();
            int[] A = new int[n];
            int[] B = new int[m];
            TreeSet<Integer> set = new TreeSet<>();
            for(int i=0;i<n;i++) {
                set.add(in.nextInt());
            }
            for(int i=0;i<m;i++) {
                set.add(in.nextInt());
            }
            for(Integer x : set) {
                System.out.print(x+" ");
            }

        }

    }

}
